package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.corona.Game;
import com.corona.game.util.TextureCache;
import java.util.ArrayList;
import java.util.Map;

/* compiled from: Player.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/PlayerLedgeJumpFast.class */
public class PlayerLedgeJumpFast extends Action {
    public Action.Layer layer;
    float xDist;
    float yDist;
    Vector2 initialPos;
    Vector2 targetPos;
    int timer1;
    ArrayList<Integer> yMovesList;
    ArrayList<Map<String, Sprite>> spriteAnim;
    Player player;
    DrawShadow drawShadow;

    public PlayerLedgeJumpFast(Game game) {
        this(game, game.player);
    }

    public PlayerLedgeJumpFast(Game game, Player player) {
        this(game, player, new PlayerStanding(game, player, false, false));
    }

    public PlayerLedgeJumpFast(Game game, Player player, Action nextAction) {
        super(new Object[0]);
        this.layer = Action.Layer.map_114;
        this.timer1 = 0;
        this.yMovesList = new ArrayList<>();
        this.spriteAnim = new ArrayList<>();
        this.player = player;
        this.nextAction = nextAction;
        this.initialPos = new Vector2(this.player.position);
        if (this.player.dirFacing.equals("up")) {
            this.targetPos = new Vector2(this.player.position.x, this.player.position.y + 16.0f);
        } else if (this.player.dirFacing.equals("down")) {
            this.targetPos = new Vector2(this.player.position.x, this.player.position.y - 16.0f);
        } else if (this.player.dirFacing.equals("left")) {
            this.targetPos = new Vector2(this.player.position.x - 16.0f, this.player.position.y);
        } else if (this.player.dirFacing.equals("right")) {
            this.targetPos = new Vector2(this.player.position.x + 16.0f, this.player.position.y);
        }
        game.insertAction(new DrawShadow());
        game.insertAction(new PlayMusic("ledge2", (Action) null));
        this.yMovesList.add(4);
        this.yMovesList.add(2);
        this.yMovesList.add(1);
        this.yMovesList.add(0);
        this.yMovesList.add(-1);
        this.yMovesList.add(-1);
        this.yMovesList.add(-2);
        this.yMovesList.add(-3);
        this.spriteAnim.add(this.player.standingSprites);
        this.spriteAnim.add(this.player.movingSprites);
        this.spriteAnim.add(this.player.movingSprites);
        this.spriteAnim.add(this.player.standingSprites);
        this.spriteAnim.add(this.player.standingSprites);
        this.spriteAnim.add(this.player.altMovingSprites);
        this.spriteAnim.add(this.player.altMovingSprites);
        this.spriteAnim.add(this.player.standingSprites);
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
        if (this.player.hmPokemon != null) {
            this.player.hmPokemon.moveDirs.add(this.player.dirFacing);
            this.player.hmPokemon.numMoves.add(Float.valueOf(1.0f));
        }
    }

    public void localStep(Game game) {
        if (this.timer1 < 16) {
            if (game.player.dirFacing.equals("up")) {
                game.player.position.y += 1.0f;
                game.cam.position.y += 1.0f;
            } else if (game.player.dirFacing.equals("down")) {
                game.cam.position.y -= 1.0f;
                game.player.position.y -= 1.0f;
            } else if (game.player.dirFacing.equals("left")) {
                game.player.position.x -= 1.0f;
                game.cam.position.x -= 1.0f;
            } else if (game.player.dirFacing.equals("right")) {
                game.player.position.x += 1.0f;
                game.cam.position.x += 1.0f;
            }
            if (this.timer1 % 2 == 1) {
                game.player.position.y += (float) this.yMovesList.get(0).intValue();
                this.yMovesList.remove(0);
                game.player.currSprite = this.spriteAnim.get(0).get(game.player.dirFacing);
                this.spriteAnim.remove(0);
            }
        } else {
            game.player.currSprite = game.player.standingSprites.get(game.player.dirFacing);
        }
        if (this.timer1 >= 19) {
            game.player.position.set(this.targetPos);
            game.cam.position.set(this.targetPos.x + 16.0f, this.targetPos.y, 0.0f);
            game.player.isNearCampfire = game.player.checkNearCampfire();
            game.actionStack.remove(this);
            game.actionStack.remove(this.drawShadow);
            game.insertAction(this.nextAction);
            if (this.player.hmPokemon != null) {
                this.player.hmPokemon.ledgeJumps.add(2);
            }
        }
        this.timer1++;
    }

    public void remoteStep(Game game) {
        this.player.network.syncTimer++;
        if (this.timer1 < 16) {
            if (this.player.dirFacing.equals("up")) {
                this.player.position.y += 1.0f;
            } else if (this.player.dirFacing.equals("down")) {
                this.player.position.y -= 1.0f;
            } else if (this.player.dirFacing.equals("left")) {
                this.player.position.x -= 1.0f;
            } else if (this.player.dirFacing.equals("right")) {
                this.player.position.x += 1.0f;
            }
            if (this.timer1 % 2 == 1) {
                this.player.position.y += (float) this.yMovesList.get(0).intValue();
                this.yMovesList.remove(0);
                this.player.currSprite = this.spriteAnim.get(0).get(this.player.dirFacing);
                this.spriteAnim.remove(0);
            }
        } else {
            this.player.currSprite = this.player.standingSprites.get(this.player.dirFacing);
        }
        if (this.timer1 >= 19) {
            this.player.position.set(this.targetPos);
            this.player.standingAction.alternate = true;
            this.player.standingAction.isRunning = false;
            game.insertAction(this.player.standingAction);
            game.actionStack.remove(this);
        }
        this.timer1++;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.player.type == Player.Type.LOCAL) {
            localStep(game);
        } else if (this.player.type == Player.Type.REMOTE) {
            remoteStep(game);
        }
    }

    /* compiled from: Player.java */
    /* loaded from: pokewilds.jar:com/pkmngen/game/PlayerLedgeJumpFast$DrawShadow.class */
    public class DrawShadow extends Action {
        public Action.Layer layer = Action.Layer.map_131;
        Texture shadow = TextureCache.get(Gdx.files.internal("shadow1.png"));

        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public DrawShadow() {
            super(new Object[0]);
            PlayerLedgeJumpFast.this = this$0;
            this$0.drawShadow = this;
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            game.mapBatch.draw(this.shadow, game.cam.position.x - 16.0f, game.cam.position.y - 4.0f);
        }
    }
}
